package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoMountInterior;
import com.muyu.danmo.service.IDanmoMountInteriorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 装裱内景照片Controller
 *
 * @author yangle
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/mountInterior")
public class DanmoMountInteriorController extends BaseController
{
    @Autowired
    private IDanmoMountInteriorService danmoMountInteriorService;

    /**
     * 查询装裱内景照片列表
     */
//    @RequiresPermissions("system:mountInterior:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoMountInterior>> list(DanmoMountInterior danmoMountInterior)
    {
        startPage();
        List<DanmoMountInterior> list = danmoMountInteriorService.selectDanmoMountInteriorList(danmoMountInterior);
        return getDataTable(list);
    }

    /**
     * 导出装裱内景照片列表
     */
//    @RequiresPermissions("system:mountInterior:export")
    @Log(title = "装裱内景照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoMountInterior danmoMountInterior)
    {
        List<DanmoMountInterior> list = danmoMountInteriorService.selectDanmoMountInteriorList(danmoMountInterior);
        ExcelUtil<DanmoMountInterior> util = new ExcelUtil<DanmoMountInterior>(DanmoMountInterior.class);
        util.exportExcel(response, list, "装裱内景照片数据");
    }

    /**
     * 获取装裱内景照片详细信息
     */
//    @RequiresPermissions("system:mountInterior:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoMountInteriorService.selectDanmoMountInteriorById(id));
    }

    /**
     * 新增装裱内景照片
     */
//    @RequiresPermissions("system:mountInterior:add")
    @Log(title = "装裱内景照片", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoMountInterior danmoMountInterior)
    {
        return toAjax(danmoMountInteriorService.insertDanmoMountInterior(danmoMountInterior));
    }

    /**
     * 修改装裱内景照片
     */
//    @RequiresPermissions("system:mountInterior:edit")
    @Log(title = "装裱内景照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoMountInterior danmoMountInterior)
    {
        return toAjax(danmoMountInteriorService.updateDanmoMountInterior(danmoMountInterior));
    }

    /**
     * 删除装裱内景照片
     */
//    @RequiresPermissions("system:mountInterior:remove")
    @Log(title = "装裱内景照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoMountInteriorService.deleteDanmoMountInteriorByIds(ids));
    }
}
